<?php
/* 
 * Commons
 */

/**
 * Description of File
 *
 * @author Sebastian
 */
class Common_View_File
{
    public static function getIcon($filename)
    {
        $filename = strtolower($filename);// file name is changed to lowercase
		ereg( ".*\.([a-zA-z0-9]{0,5})$", $filename, $regs ); //gets extension of file
		$f_ext = $regs[1];
		
        $icon = null;

		switch ($f_ext) {//known file types

		   case "jpg": $icon = "image.gif"; break;
		   case "jpeg": $icon = "image.gif"; break;
		   case "gif": $icon = "image.gif"; break;
		   case "png": $icon = "image.gif"; break;
		   case "txt": $icon = "file.gif"; break;
		   case "html": $icon = "file.gif"; break;
		   case "htm": $icon = "file.gif"; break;
		   case "doc": $icon = "doc.gif";break;
		   //case "exe": $icon = "exe.gif";break;
		   case "pdf": $icon = "pdf.gif";break;
		   case "ai": $icon = "pdf.gif";break;
		   case "eps": $icon = "pdf.gif";break;
		   case "ps": $icon = "pdf.gif";break;
		   case "xls": $icon = "excel.gif";break;
		   case "ppt": $icon = "presentacion.gif";break;
		   case "zip": $icon = "rar.gif";break;
		   case "rar": $icon = "rar.gif";break;
		   case "mid": $icon = "audio.gif";break;
		   case "kar": $icon = "audio.gif";break;
		   case "mp3": $icon = "audio.gif";break;
		   case "wav": $icon = "audio.gif";break;
		   case "bmp": $icon = "image.gif";break;
		   case "tiff": $icon = "image.gif";break;
		   case "tif": $icon = "image.gif";break;
		   case "asc": $icon = "file.gif";break;
		   case "rtf": $icon = "doc.gif";break;
		   case "mpeg": $icon = "video.gif";break;
		   case "mpg": $icon = "video.gif";break;
		   case "mpe": $icon = "video.gif";break;
		   case "avi": $icon = "video.gif";break;
		   case "odt": $icon = "doc.gif";break;
		   case "ods": $icon = "excel.gif";break;
		   case ""   : $icon = "folder.gif";break;
           default : $icon = "file.gif";break;

		}


		return $icon; //returns the type
    }
}
?>
